package com.boochy.test.im;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Client {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://connector.cloopen.com:8889/56002/8a216da85ed1f7bf015f0058a1b60563/2017-10-17/09-52/1508205135630203206.jpg");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setConnectTimeout(5 * 1000);
            InputStream inputStream = connection.getInputStream();
            
            byte[] tmp = new byte[1024];
            int length;
            OutputStream outputStream = new FileOutputStream("D:" + File.separator + "eee.jpg");
            while ((length = inputStream.read(tmp)) != -1) {
            	System.out.println(inputStream.available());
                outputStream.write(tmp, 0, length);
            }
            outputStream.flush();
            outputStream.close();
            
            inputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
